Make Parsers and Compilers configurable #136
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
My Goal is to extend ngx-translate-extract to use as a library using my custom implementantion of Parsers and compilers that extends the standard implementations.
I've added a method to ParserInterface (preprocessKeys) in order to rewrite extracted keys before adding them to TranslateCollection. In the standard Parser the method implementation simply return the input.
In order to load my custom implementations i've used InversifyJS: the default implementations is still the same but i can write my custom app with ngx-translate-extract as dependency and plug my custom implementations.
this is done by adding to cli.js some configuration lines
`#! /usr/bin/env node
//need to be imported once per application: @see inversify/InversifyJS#262 (comment)
let reflectMetadata = require('reflect-metadata');
//IoC configuration: imported here to allow redefintion for usage as library
let inversifyConfig = require('../dist/ioc/inversify.config');
let inversifyConfigParsers = require('../dist/ioc/inversify.config.parsers.custom-impl');
let container = inversifyConfig.default;
inversifyConfigParsers.configParsers(container); // load custom parsers
inversifyConfigParsers.configCompilers(container); // load custom compilers
let cli = require('../dist/cli/cli');
cli.extractTask.execute();
`
Do you think it's possible to merge this?